//
//  LoginRegisterController.m
//  Budejie
//
//  Created by 远成物流 on 2017/6/6.
//  Copyright © 2017年 陈梦佳. All rights reserved.
//

#import "LoginRegisterController.h"
#import "LoginRegisterView.h"
#import "FastLoginView.h"

@interface LoginRegisterController ()

@property (weak, nonatomic) IBOutlet UIButton *cancelBtn;
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;
@property (weak, nonatomic) IBOutlet UIView *middleView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIView *topView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *middleViewLeading;

@end

@implementation LoginRegisterController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //添加登录
    LoginRegisterView *loginView = [LoginRegisterView initLoginView];
    [self.middleView addSubview:loginView];
    
    //添加注册
    LoginRegisterView *registerView = [LoginRegisterView initRegisterView];
    [self.middleView addSubview:registerView];
    
    //添加底部
    FastLoginView *fastLogin = [FastLoginView initFastLogin];
    [self.bottomView addSubview:fastLogin];
}

//布局控件
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    LoginRegisterView *loginView = self.middleView.subviews[0];
    loginView.frame = CGRectMake(0, 0, self.middleView.width_sd*0.5, self.middleView.height_sd);
    
    LoginRegisterView *registerView = self.middleView.subviews[1];
    registerView.frame = CGRectMake(self.middleView.width_sd*0.5, 0, self.middleView.width_sd*0.5, self.middleView.height_sd);
    
    FastLoginView *fastLogin = self.bottomView.subviews.firstObject;
    fastLogin.frame = self.bottomView.bounds;
}

//注册账号
- (IBAction)registerAccount:(id)sender {
    
    UIButton *button = (UIButton *)sender;
    
    button.selected = !button.selected;
    
    _middleViewLeading.constant = _middleViewLeading.constant == 0 ? -self.middleView.width_sd * 0.5 : 0;
    
    [UIView animateWithDuration:.3 animations:^{
        [self.view layoutIfNeeded];
    }];
}


- (IBAction)dismissCurrentView:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
